<!DOCTYPE HTML>
<html lang="zh-CN">


<head>
    <meta charset="utf-8">
    <meta name="keywords" content="centos7.9部署的kolla-openstack官方教程, 搞机の基地">
    <meta name="description" content="基于centos7.9部署的kolla-openstack虚拟化IAAS平台">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="renderer" content="webkit|ie-stand|ie-comp">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <meta name="referrer" content="no-referrer-when-downgrade">
    <!-- Global site tag (gtag.js) - Google Analytics -->


    <title>centos7.9部署的kolla-openstack官方教程 | 搞机の基地</title>
    <link rel="icon" type="image/png" href="/favicon.png">
    


    <!-- bg-cover style     -->



<link rel="stylesheet" type="text/css" href="/libs/awesome/css/all.min.css">
<link rel="stylesheet" type="text/css" href="/libs/materialize/materialize.min.css">
<link rel="stylesheet" type="text/css" href="/libs/aos/aos.css">
<link rel="stylesheet" type="text/css" href="/libs/animate/animate.min.css">
<link rel="stylesheet" type="text/css" href="/libs/lightGallery/css/lightgallery.min.css">
<link rel="stylesheet" type="text/css" href="/css/matery.css">
<link rel="stylesheet" type="text/css" href="/css/my.css">
<link rel="stylesheet" type="text/css" href="/css/dark.css" media="none" onload="if(media!='all')media='all'">




    <link rel="stylesheet" href="/libs/tocbot/tocbot.css">
    <link rel="stylesheet" href="/css/post.css">




    
        <link rel="stylesheet" type="text/css" href="/css/reward.css">
    



    <script src="/libs/jquery/jquery-3.6.0.min.js"></script>

<meta name="generator" content="Hexo 6.3.0"></head>


<body>
    <header class="navbar-fixed">
    <nav id="headNav" class="bg-color nav-transparent">
        <div id="navContainer" class="nav-wrapper container">
            <div class="brand-logo">
                <a href="/" class="waves-effect waves-light">
                    
                    <img src="/medias/logo.png" class="logo-img" alt="LOGO">
                    
                    <span class="logo-span">搞机の基地</span>
                </a>
            </div>
            

<a href="#" data-target="mobile-nav" class="sidenav-trigger button-collapse"><i class="fas fa-bars"></i></a>
<ul class="right nav-menu">
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/" class="waves-effect waves-light">
      
      <i class="fas fa-home" style="zoom: 0.6;"></i>
      
      <span>首页</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="" class="waves-effect waves-light">

      
      <i class="fas fa-project-diagram"" style="zoom: 0.6;"></i>
      
      <span>项目</span>
      <i class="fas fa-chevron-down" aria-hidden="true" style="zoom: 0.6;"></i>
    </a>
    <ul class="sub-nav menus_item_child ">
      
      <li>
        <a target="_blank" rel="noopener" href="https://github.com/liangyoufeng/devpos">
          
          <span>devops</span>
        </a>
      </li>
      
    </ul>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/tags" class="waves-effect waves-light">
      
      <i class="fas fa-tags" style="zoom: 0.6;"></i>
      
      <span>标签</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/categories" class="waves-effect waves-light">
      
      <i class="fas fa-bookmark" style="zoom: 0.6;"></i>
      
      <span>分类</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/archives" class="waves-effect waves-light">
      
      <i class="fas fa-archive" style="zoom: 0.6;"></i>
      
      <span>归档</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/about" class="waves-effect waves-light">
      
      <i class="fas fa-user-circle" style="zoom: 0.6;"></i>
      
      <span>关于</span>
    </a>
    
  </li>
  
  <li>
    <a href="#searchModal" class="modal-trigger waves-effect waves-light">
      <i id="searchIcon" class="fas fa-search" title="搜索" style="zoom: 0.85;"></i>
    </a>
  </li>
  <li>
    <a href="javascript:;" class="waves-effect waves-light" onclick="switchNightMode()" title="深色/浅色模式" >
      <i id="sum-moon-icon" class="fas fa-sun" style="zoom: 0.85;"></i>
    </a>
  </li>
</ul>


<div id="mobile-nav" class="side-nav sidenav">

    <div class="mobile-head bg-color">
        
        <img src="/medias/logo.png" class="logo-img circle responsive-img">
        
        <div class="logo-name">搞机の基地</div>
        <div class="logo-desc">
            
            用来测试知识库
            
        </div>
    </div>

    <ul class="menu-list mobile-menu-list">
        
        <li class="m-nav-item">
	  
		<a href="/" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-home"></i>
			
			首页
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="javascript:;">
			
				<i class="fa-fw fas fa-project-diagram""></i>
			
			项目
			<span class="m-icon"><i class="fas fa-chevron-right"></i></span>
		</a>
            <ul  style="background:  ;" >
              
                <li>

                  <a target="_blank" rel="noopener" href="https://github.com/liangyoufeng/devpos " style="margin-left:75px">
				  
		          <span>devops</span>
                  </a>
                </li>
              
            </ul>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/tags" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-tags"></i>
			
			标签
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/categories" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-bookmark"></i>
			
			分类
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/archives" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-archive"></i>
			
			归档
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/about" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-user-circle"></i>
			
			关于
		</a>
          
        </li>
        
        
        <li><div class="divider"></div></li>
        <li>
            <a href="https://github.com/blinkfox/hexo-theme-matery" class="waves-effect waves-light" target="_blank">
                <i class="fab fa-github-square fa-fw"></i>Fork Me
            </a>
        </li>
        
    </ul>
</div>


        </div>

        
            <style>
    .nav-transparent .github-corner {
        display: none !important;
    }

    .github-corner {
        position: absolute;
        z-index: 10;
        top: 0;
        right: 0;
        border: 0;
        transform: scale(1.1);
    }

    .github-corner svg {
        color: #0f9d58;
        fill: #fff;
        height: 64px;
        width: 64px;
    }

    .github-corner:hover .octo-arm {
        animation: a 0.56s ease-in-out;
    }

    .github-corner .octo-arm {
        animation: none;
    }

    @keyframes a {
        0%,
        to {
            transform: rotate(0);
        }
        20%,
        60% {
            transform: rotate(-25deg);
        }
        40%,
        80% {
            transform: rotate(10deg);
        }
    }
</style>

<a href="https://github.com/blinkfox/hexo-theme-matery" class="github-corner tooltipped hide-on-med-and-down" target="_blank"
   data-tooltip="Fork Me" data-position="left" data-delay="50">
    <svg viewBox="0 0 250 250" aria-hidden="true">
        <path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
        <path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
              fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path>
        <path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
              fill="currentColor" class="octo-body"></path>
    </svg>
</a>
        
    </nav>

</header>

    



<div class="bg-cover pd-header post-cover" style="background-image: url('/images/centos7%E9%83%A8%E7%BD%B2kolla-openstack%E5%AE%98%E6%96%B9%E6%95%99%E7%A8%8B/top.jpg')">
    <div class="container" style="right: 0px;left: 0px;">
        <div class="row">
            <div class="col s12 m12 l12">
                <div class="brand">
                    <h1 class="description center-align post-title">centos7.9部署的kolla-openstack官方教程</h1>
                </div>
            </div>
        </div>
    </div>
</div>




<main class="post-container content">

    
    <div class="row">
    <div id="main-content" class="col s12 m12 l9">
        <!-- 文章内容详情 -->
<div id="artDetail">
    <div class="card">
        <div class="card-content article-info">
            <div class="row tag-cate">
                <div class="col s7">
                    
                    <div class="article-tag">
                        
                            <a href="/tags/%E4%BA%91%E8%AE%A1%E7%AE%97/">
                                <span class="chip bg-color">云计算</span>
                            </a>
                        
                            <a href="/tags/%E8%99%9A%E6%8B%9F%E5%8C%96%E6%8A%80%E6%9C%AF/">
                                <span class="chip bg-color">虚拟化技术</span>
                            </a>
                        
                            <a href="/tags/iaas/">
                                <span class="chip bg-color">iaas</span>
                            </a>
                        
                            <a href="/tags/kolla-openstack/">
                                <span class="chip bg-color">kolla-openstack</span>
                            </a>
                        
                    </div>
                    
                </div>
                <div class="col s5 right-align">
                    
                    <div class="post-cate">
                        <i class="fas fa-bookmark fa-fw icon-category"></i>
                        
                            <a href="/categories/%E4%BA%91%E8%AE%A1%E7%AE%97/" class="post-category">
                                云计算
                            </a>
                        
                    </div>
                    
                </div>
            </div>

            <div class="post-info">
                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-minus fa-fw"></i>发布日期:&nbsp;&nbsp;
                    2023-06-12
                </div>
                

                

                

                

                
            </div>
        </div>
        <hr class="clearfix">

        
        <!-- 是否加载使用自带的 prismjs. -->
        <link rel="stylesheet" href="/libs/prism/prism.min.css">
        

        

        <div class="card-content article-card-content">
            <div id="articleContent">
                <p>这是一个基于centos7.9部署的kolla-openstack平台，适合用于学习……<br>这篇文档是基于官方文档修改后的，如有问题请多多看日志谷歌。<br>看准IP下手，还有账号密码<br>版本为train版</p>
<h3 id="安装常用软件和安装docker"><a href="#安装常用软件和安装docker" class="headerlink" title="安装常用软件和安装docker"></a>安装常用软件和安装docker</h3><pre class="line-numbers language-bash" data-language="bash"><code class="language-bash"><span class="token function">cat</span> <span class="token operator">></span> /etc/yum.repos.d/epel.repo <span class="token operator">&lt;&lt;</span> <span class="token string">EOF
[epel]
name=Extra Packages for Enterprise Linux 7 - \<span class="token variable">$basearch</span>
baseurl=https://mirrors.ustc.edu.cn/epel/7/\<span class="token variable">$basearch</span>
failovermethod=priority
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
EOF</span>

yum <span class="token function">install</span> <span class="token parameter variable">-y</span> python-devel libffi-devel gcc openssl-devel libselinux-python lvm2 <span class="token function">vim</span>
yum <span class="token function">install</span> <span class="token parameter variable">-y</span> chrony <span class="token function">vim</span> net-tools bash-completion ipset ipvsadm conntrack jq iptables <span class="token function">curl</span> sysstat libseccomp <span class="token function">wget</span> yum-utils device-mapper-persistent-data lvm2 <span class="token function">git</span> ntpdate
yum <span class="token parameter variable">-y</span> <span class="token function">install</span> iptables-services <span class="token operator">&amp;&amp;</span> systemctl start iptables <span class="token operator">&amp;&amp;</span> systemctl <span class="token builtin class-name">enable</span> iptables <span class="token operator">&amp;&amp;</span> iptables <span class="token parameter variable">-F</span> <span class="token operator">&amp;&amp;</span> <span class="token function">service</span> iptables save


<span class="token function">cat</span> <span class="token operator">></span> /etc/sysconfig/network-scripts/ifcfg-ens33 <span class="token operator">&lt;&lt;</span> <span class="token string">EOF
TYPE=Ethernet
BOOTPROTO=static
NAME=ens33
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.233.41
NETMASK=255.255.255.0
GATEWAY=192.168.233.2
DNS1=114.114.114.114
EOF</span>

<span class="token function">cat</span> <span class="token operator">></span> /etc/sysconfig/network-scripts/ifcfg-ens34 <span class="token operator">&lt;&lt;</span> <span class="token string">EOF
TYPE=Ethernet
BOOTPROTO=static
NAME=ens34
DEVICE=ens34
ONBOOT=yes
IPADDR=172.168.233.41
NETMASK=255.255.255.0
EOF</span>

<span class="token function">cat</span> <span class="token operator">></span> /etc/sysconfig/network-scripts/ifcfg-ens37 <span class="token operator">&lt;&lt;</span> <span class="token string">EOF
TYPE=Ethernet
BOOTPROTO=none
NAME=ens37
DEVICE=ens37
ONBOOT=yes
EOF</span>


systemctl stop NetworkManager <span class="token operator">&amp;&amp;</span> systemctl disable NetworkManager

systemctl disable firewalld <span class="token operator">&amp;&amp;</span> systemctl stop firewalld

<span class="token function">sed</span> <span class="token parameter variable">-i</span> <span class="token string">'s/^SELINUX=enforcing$/SELINUX=disabled/'</span> /etc/selinux/config <span class="token operator">&amp;&amp;</span> setenforce <span class="token number">0</span>
<span class="token comment">#同步时间</span>
ntpdate <span class="token parameter variable">-u</span> ntp.aliyun.com
hwclock <span class="token parameter variable">-w</span>

yum <span class="token function">install</span> docker-ce-19.03.15-3.el7 <span class="token parameter variable">-y</span>
systemctl daemon-reload <span class="token operator">&amp;&amp;</span> systemctl <span class="token builtin class-name">enable</span> <span class="token function">docker</span> <span class="token operator">&amp;&amp;</span> systemctl restart <span class="token function">docker</span>

<span class="token function">cat</span> <span class="token operator">>></span> /etc/docker/daemon.json <span class="token operator">&lt;&lt;</span> <span class="token string">EOF
&#123;
"registry-mirrors": [
"https://docker.mirrors.ustc.edu.cn",
"http://hub-mirror.c.163.com"
]
&#125;
EOF</span>

<span class="token function">mkdir</span> <span class="token parameter variable">-p</span> /etc/systemd/system/docker.service.d
<span class="token function">cat</span> <span class="token operator">>></span> /etc/systemd/system/docker.service.d/kolla.conf <span class="token operator">&lt;&lt;</span> <span class="token string">EOF
[Service]
MountFlags=shared
EOF</span>

systemctl daemon-reload <span class="token operator">&amp;&amp;</span> systemctl <span class="token builtin class-name">enable</span> <span class="token function">docker</span> <span class="token operator">&amp;&amp;</span> systemctl restart <span class="token function">docker</span>

<span class="token function">cat</span> <span class="token operator">></span> /etc/chrony.conf <span class="token operator">&lt;&lt;</span> <span class="token string">EOF
pool ntp.aliyun.com iburst
driftfile /var/lib/chrony/drift
makestep 1.0 3
rtcsync
keyfile /etc/chrony.keys
leapsectz right/UTC
logdir /var/log/chrony
EOF</span>
systemctl restart chronyd

hostnamectl set-hostname allinone

<span class="token builtin class-name">echo</span> <span class="token string">"192.168.233.41 allinone"</span> <span class="token operator">></span> /etc/hosts

ssh-keygen <span class="token parameter variable">-t</span> rsa <span class="token parameter variable">-P</span> <span class="token string">""</span> <span class="token parameter variable">-f</span> /root/.ssh/id_rsa

ssh-copy-id allinone

<span class="token function">cat</span> <span class="token operator">>></span> /etc/sysctl.conf <span class="token operator">&lt;&lt;</span> <span class="token string">EOF
#开启网桥模式【重要】
net.bridge.bridge-nf-call-iptables=1
#开启网桥模式【重要】
net.bridge.bridge-nf-call-ip6tables=1
net.ipv4.ip_forward=1
#内核4.1以上已弃用参数net.ipv4.tcp_tw_recycle=0
#net.ipv4.tcp_tw_recycle=0
#禁止使用swap空间，只有当系统OOM时才允许使用它
vm.swappiness=0
#不检查物理内存是否够用
vm.overcommit_memory=1
#开启OOM
vm.panic_on_oom=0
fs.inotify.max_user_instances=8192
fs.inotify.max_user_watches=1048576
fs.file-max=52706963
fs.nr_open=52706963
#关闭ipv6【重要】
net.ipv6.conf.all.disable_ipv6=1
net.netfilter.nf_conntrack_max=2310720
#设置arp缓存数值
net.ipv4.neigh.default.gc_thresh1=1024
net.ipv4.neigh.default.gc_thresh2=2048
net.ipv4.neigh.default.gc_thresh3=4096
EOF</span>

<span class="token function">sysctl</span> <span class="token parameter variable">-p</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<h3 id="安装kolla-ansible使用虚拟方式"><a href="#安装kolla-ansible使用虚拟方式" class="headerlink" title="安装kolla-ansible使用虚拟方式"></a>安装kolla-ansible使用虚拟方式</h3><pre class="line-numbers language-bash" data-language="bash"><code class="language-bash">
yum <span class="token function">install</span> python-devel libffi-devel gcc openssl-devel libselinux-python python3-devel python3-libselinux python3-pip ansible <span class="token parameter variable">-y</span>

yum <span class="token function">install</span> python-virtualenv <span class="token parameter variable">-y</span>

python3 <span class="token parameter variable">-m</span> venv /path/to/venv
<span class="token builtin class-name">source</span> /path/to/venv/bin/activate

<span class="token comment">#python 2.7已弃用</span>
<span class="token comment">#virtualenv /path/to/virtualenv</span>
<span class="token comment">#source /path/to/virtualenv/bin/activate</span>

<span class="token comment">#使用清华pypi源</span>
<span class="token function">mkdir</span> ~/.pip
<span class="token function">cat</span> <span class="token operator">></span> ~/.pip/pip.conf <span class="token operator">&lt;&lt;</span> <span class="token string">EOF
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = https://pypi.tuna.tsinghua.edu.cn
EOF</span>

pip <span class="token function">install</span> <span class="token parameter variable">-U</span> pip
pip <span class="token function">install</span> <span class="token parameter variable">-U</span> setuptools
pip <span class="token function">install</span> <span class="token string">'ansible&lt;2.10'</span>
pip <span class="token function">install</span> pbr
pip <span class="token function">install</span> kolla-ansible

<span class="token function">sudo</span> <span class="token function">mkdir</span> <span class="token parameter variable">-p</span> /etc/kolla
<span class="token function">sudo</span> <span class="token function">chown</span> <span class="token environment constant">$USER</span><span class="token builtin class-name">:</span><span class="token environment constant">$USER</span> /etc/kolla


<span class="token function">cp</span> <span class="token parameter variable">-r</span> /path/to/venv/share/kolla-ansible/etc_examples/kolla/* /etc/kolla/

<span class="token builtin class-name">cd</span> /root/

<span class="token function">cp</span> <span class="token parameter variable">-r</span> /path/to/venv/share/kolla-ansible/ansible/inventory/* /root/

<span class="token comment">#cp -r /path/to/virtualenv/share/kolla-ansible/etc_examples/kolla/* /etc/kolla</span>
<span class="token comment">#cp /path/to/virtualenv/share/kolla-ansible/ansible/inventory/* /root/</span>

<span class="token comment"># 对ansible进行配置</span>
<span class="token function">mkdir</span> /etc/ansible/
<span class="token function">cat</span> <span class="token operator">></span> /etc/ansible/ansible.cfg <span class="token operator">&lt;&lt;</span> <span class="token string">EOF
[defaults]
# 跳过首次连接验证提示
host_key_checking=False
# 利用管道替换默认的拷贝模块
pipelining=True
# 执行时的并发数
forks=100
EOF</span>

<span class="token comment">#测试通不通，需要自行准备ssh密钥和免密登录</span>
ansible <span class="token parameter variable">-i</span> all-in-one all <span class="token parameter variable">-m</span> <span class="token function">ping</span>

<span class="token comment">#我这里使用了lvm作为cinder后端，如果使用了ceph，不需要这一步，或者不使用cinder</span>
pvcreate /dev/sdb
pvcreate /dev/sdc
vgcreate cinder-volumes /dev/sdb /dev/sdc<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>



<h3 id="开始配置kolla-ansible"><a href="#开始配置kolla-ansible" class="headerlink" title="开始配置kolla-ansible"></a>开始配置kolla-ansible</h3><pre class="line-numbers language-bash" data-language="bash"><code class="language-bash"><span class="token comment">#生成随机密码</span>
kolla-genpwd

<span class="token comment">#修改admin密码</span>
<span class="token function">sed</span> <span class="token parameter variable">-i</span> <span class="token string">'s/^keystone_admin_password.*/keystone_admin_password: admin@123/'</span> /etc/kolla/passwords.yml

<span class="token comment">#添加配置文件</span>
<span class="token function">cat</span> <span class="token operator">>></span> /etc/kolla/globals.yml <span class="token operator">&lt;&lt;</span> <span class="token string">EOF
kolla_base_distro: "centos"
kolla_install_type: "source"
openstack_release: "train"
kolla_internal_vip_address: "192.168.233.240"
neutron_tenant_network_types: "vxlan,vlan,flat"
network_interface: "ens33"
#tunnel_interface: "ens34"
neutron_external_interface: "ens37"
enable_cinder: "yes"
#enable_cinder_backup: "yes"
#如果启动cinder，但又不启用后端存储跑检查会不通过，为对接外部ceph用的，如果不知道改为yes
enable_cinder_backend_lvm: "yes"
#enable_cinder_backend_lvm: "no"
nova_compute_virt_type: "qemu"
#是否启用ha
enable_haproxy: "yes"
EOF</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>



<h3 id="提示技巧"><a href="#提示技巧" class="headerlink" title="提示技巧"></a>提示技巧</h3><pre class="line-numbers language-bash" data-language="bash"><code class="language-bash"><span class="token comment">#提示技巧</span>
kolla-ansible <span class="token parameter variable">-i</span> INVENTORY deploy用于部署和启动所有 Kolla 器皿。

kolla-ansible <span class="token parameter variable">-i</span> INVENTORY destroy用于清理容器和 群集中的卷。

kolla-ansible <span class="token parameter variable">-i</span> INVENTORY mariadb_recovery用于恢复 完全停止MariaDB集群。

kolla-ansible <span class="token parameter variable">-i</span> INVENTORY prechecks用于检查是否所有要求 在部署每个 OpenStack 服务之前满足。

kolla-ansible <span class="token parameter variable">-i</span> INVENTORY post-deploy用于在部署时执行部署后 节点以获取管理员 OpenRC 文件。

kolla-ansible <span class="token parameter variable">-i</span> INVENTORY pull用于拉取容器的所有映像。

kolla-ansible <span class="token parameter variable">-i</span> INVENTORY reconfigure用于重新配置 OpenStack 服务。

kolla-ansible <span class="token parameter variable">-i</span> INVENTORY upgrade用于升级现有的OpenStack 环境。

kolla-ansible <span class="token parameter variable">-i</span> INVENTORY stop用于停止正在运行的容器。

kolla-ansible <span class="token parameter variable">-i</span> INVENTORY deploy-containers用于检查和 必要的更新容器，而不生成配置。

kolla-ansible <span class="token parameter variable">-i</span> INVENTORY prune-images用于修剪孤立的 Docker 主机上的图像。

kolla-ansible <span class="token parameter variable">-i</span> INVENTORY1 <span class="token parameter variable">-i</span> INVENTORY2 <span class="token punctuation">..</span>.可以有多个库存 通过传递 OR 命令行选项多个来指定 次。这对于在多个环境之间共享配置非常有用。 任何常见配置都可以在 中设置，并且可以 用于设置特定于环境的详细信息。--inventory-iINVENTORY1INVENTORY2

kolla-ansible <span class="token parameter variable">-i</span> INVENTORY gather-facts用于收集 Ansible 事实， 例如，填充事实缓存。<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>





<h3 id="开始部署kolla-ansible"><a href="#开始部署kolla-ansible" class="headerlink" title="开始部署kolla-ansible"></a>开始部署kolla-ansible</h3><pre class="line-numbers language-bash" data-language="bash"><code class="language-bash"><span class="token comment"># 1.部署依赖的引导服务器:安装一些软件比如docker之类的包</span>
kolla-ansible <span class="token parameter variable">-i</span> ./all-in-one bootstrap-servers

<span class="token comment">#建议先将镜像pull下楼再部署，因为不知道镜像要pull多久，要注意，镜像pull过程中，会改变/etc/docker/daemon.json配置文件，导致上面配置的国内源无法使用，一直卡状态，需要执行一遍后，注意观察网络流量是否很低或者配置文件是否发生改变，然后改回去，ctrl+c掉，重新pull。</span>
<span class="token comment">###########################################改回去docker配置文件####################</span>
<span class="token function">cat</span> <span class="token operator">>></span> /etc/docker/daemon.json <span class="token operator">&lt;&lt;</span> <span class="token string">EOF
&#123;
"registry-mirrors": [
"https://docker.mirrors.ustc.edu.cn",
"http://hub-mirror.c.163.com"

]
&#125;
EOF</span>
<span class="token comment">#########################################改回去docker配置文件#######################</span>
kolla-ansible <span class="token parameter variable">-i</span> ./all-in-one pull

<span class="token comment"># 2.对主机进行部署前检查</span>
kolla-ansible <span class="token parameter variable">-i</span> ./all-in-one prechecks

<span class="token comment">#注意：在进行第二步命令时如果报错，请执行以下命令进行规避。</span>
<span class="token comment"># 退出虚拟环境</span>
deactivate
<span class="token comment"># 安装新版pip，下载比较慢可以在windows用idm下载在拷贝进去执行python get-pip.py</span>
<span class="token function">curl</span>  https://bootstrap.pypa.io/pip/2.7/get-pip.py <span class="token operator">|</span> python
<span class="token comment"># 设置pip加速</span>
pip config <span class="token builtin class-name">set</span> global.index-url  https://mirrors.aliyun.com/pypi/simple/
<span class="token comment"># 使用pip安装一些python包</span>
pip <span class="token function">install</span> requests
pip <span class="token function">install</span> <span class="token assign-left variable">docker</span><span class="token operator">==</span><span class="token number">4.4</span>.4
pip <span class="token function">install</span> websocket-client<span class="token operator">==</span><span class="token number">0.59</span>.0

<span class="token comment">#然后重新执行kolla-ansible -i ./all-in-one prechecks检查环境是否通过</span>
kolla-ansible <span class="token parameter variable">-i</span> ./all-in-one prechecks
<span class="token comment">#通过后再执行部署</span>
kolla-ansible <span class="token parameter variable">-i</span> ./all-in-one deploy

<span class="token comment"># 3.开始部署OpenStack</span>
kolla-ansible <span class="token parameter variable">-i</span> ./all-in-one deploy

部署完成后生成rc文件
kolla-ansible <span class="token parameter variable">-i</span> ./all-in-one  post-deploy

<span class="token comment">#安装客户端</span>
yum <span class="token function">install</span> centos-release-openstack-train  <span class="token parameter variable">-y</span>
yum makecache fast 
yum <span class="token function">install</span> python-openstackclient openstack-selinux <span class="token parameter variable">-y</span>

<span class="token builtin class-name">source</span> /etc/kolla/admin-openrc.sh
<span class="token function">cp</span> /etc/kolla/admin-openrc.sh /root/

<span class="token function">mkdir</span> <span class="token parameter variable">-p</span> /opt/cache/files/
<span class="token comment">#上传镜像到/opt/cache/files/目录，因为脚本下载的太慢了，自己用idm下载上传进去，固定版本cirros-0.4.0-x86_64-disk.img</span>
<span class="token comment">#验证初始化环境，修改桥接网络，为自己桥接网段，比如我这里nat是管理网192.168.233.0/24，桥接是外部网：192.168.31.0/24</span>
<span class="token function">vim</span> /path/to/virtualenv/share/kolla-ansible/init-runonce
<span class="token assign-left variable">EXT_NET_CIDR</span><span class="token operator">=</span><span class="token variable">$&#123;EXT_NET_CIDR<span class="token operator">:-</span>'192.168.31.0<span class="token operator">/</span>24'&#125;</span>
<span class="token assign-left variable">EXT_NET_RANGE</span><span class="token operator">=</span><span class="token variable">$&#123;EXT_NET_RANGE<span class="token operator">:-</span>'start=192.168.31.150<span class="token operator">,</span>end=192.168.31.199'&#125;</span>
<span class="token assign-left variable">EXT_NET_GATEWAY</span><span class="token operator">=</span><span class="token variable">$&#123;EXT_NET_GATEWAY<span class="token operator">:-</span>'192.168.31.1'&#125;</span>

<span class="token comment">#运行测试，会创建很多东西</span>
<span class="token function">sh</span> /path/to/virtualenv/share/kolla-ansible/init-runonce<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>



<h3 id="安装skyline"><a href="#安装skyline" class="headerlink" title="安装skyline"></a>安装skyline</h3><pre class="line-numbers language-bash" data-language="bash"><code class="language-bash"><span class="token comment">#</span>
<span class="token function">rm</span> <span class="token parameter variable">-rf</span> /tmp/skyline <span class="token operator">&amp;&amp;</span> <span class="token function">mkdir</span> /tmp/skyline <span class="token operator">&amp;&amp;</span> <span class="token function">mkdir</span> /var/log/skyline <span class="token operator">&amp;&amp;</span> <span class="token function">mkdir</span> /etc/skyline

<span class="token comment">#创建skyline数据库和访问密码，mysql密码在 cat /etc/kolla/passwords.yml | grep -w database_password</span>

<span class="token assign-left variable">tmp_mysql_password</span><span class="token operator">=</span><span class="token variable"><span class="token variable">`</span><span class="token function">cat</span> /etc/kolla/passwords.yml <span class="token operator">|</span> <span class="token function">grep</span> <span class="token parameter variable">-w</span> database_password<span class="token operator">|</span><span class="token function">awk</span> <span class="token string">'&#123;print $2&#125;'</span><span class="token variable">`</span></span>

<span class="token function">docker</span> <span class="token builtin class-name">exec</span> <span class="token parameter variable">-it</span> mariadb mysql <span class="token parameter variable">-uroot</span> -p<span class="token variable">$tmp_mysql_password</span> <span class="token parameter variable">-e</span> <span class="token string">"CREATE DATABASE IF NOT EXISTS skyline DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;"</span>
<span class="token function">docker</span> <span class="token builtin class-name">exec</span> <span class="token parameter variable">-it</span> mariadb mysql <span class="token parameter variable">-uroot</span> -p<span class="token variable">$tmp_mysql_password</span> <span class="token parameter variable">-e</span> <span class="token string">"GRANT ALL PRIVILEGES ON skyline.* TO 'skyline'@'localhost' IDENTIFIED BY 'Skyline_123';"</span>
<span class="token function">docker</span> <span class="token builtin class-name">exec</span> <span class="token parameter variable">-it</span> mariadb mysql <span class="token parameter variable">-uroot</span> -p<span class="token variable">$tmp_mysql_password</span> <span class="token parameter variable">-e</span> <span class="token string">"GRANT ALL PRIVILEGES ON skyline.* TO 'skyline'@'%'  IDENTIFIED BY 'Skyline_123';"</span>

<span class="token comment">#查看当前环境oc配置文件，并将变量赋予进入keystone容器中</span>
<span class="token function">cat</span> /etc/kolla/admin-openrc.sh
<span class="token builtin class-name">export</span> <span class="token assign-left variable">OS_PROJECT_DOMAIN_NAME</span><span class="token operator">=</span>Default
<span class="token builtin class-name">export</span> <span class="token assign-left variable">OS_USER_DOMAIN_NAME</span><span class="token operator">=</span>Default
<span class="token builtin class-name">export</span> <span class="token assign-left variable">OS_PROJECT_NAME</span><span class="token operator">=</span>admin
<span class="token builtin class-name">export</span> <span class="token assign-left variable">OS_TENANT_NAME</span><span class="token operator">=</span>admin
<span class="token builtin class-name">export</span> <span class="token assign-left variable">OS_USERNAME</span><span class="token operator">=</span>admin
<span class="token builtin class-name">export</span> <span class="token assign-left variable">OS_PASSWORD</span><span class="token operator">=</span>admin@123
<span class="token builtin class-name">export</span> <span class="token assign-left variable">OS_AUTH_URL</span><span class="token operator">=</span>http://192.168.233.240:35357/v3
<span class="token builtin class-name">export</span> <span class="token assign-left variable">OS_INTERFACE</span><span class="token operator">=</span>internal
<span class="token builtin class-name">export</span> <span class="token assign-left variable">OS_ENDPOINT_TYPE</span><span class="token operator">=</span>internalURL
<span class="token builtin class-name">export</span> <span class="token assign-left variable">OS_IDENTITY_API_VERSION</span><span class="token operator">=</span><span class="token number">3</span>
<span class="token builtin class-name">export</span> <span class="token assign-left variable">OS_REGION_NAME</span><span class="token operator">=</span>RegionOne
<span class="token builtin class-name">export</span> <span class="token assign-left variable">OS_AUTH_PLUGIN</span><span class="token operator">=</span>password
<span class="token comment">#进入keystone容器，创建skyline用户和密码，加入到admin角色中</span>
<span class="token function">docker</span> <span class="token builtin class-name">exec</span> <span class="token parameter variable">-it</span> keystone <span class="token function">bash</span>
openstack user create <span class="token parameter variable">--domain</span> default <span class="token parameter variable">--password</span> Skyline_123 skyline
openstack role <span class="token function">add</span> <span class="token parameter variable">--project</span> <span class="token function">service</span> <span class="token parameter variable">--user</span> skyline admin


<span class="token comment">#退出容器回到外面控制执行，注意更改IP和密码</span>
<span class="token function">cat</span> <span class="token operator">></span> /etc/skyline/skyline.yaml <span class="token operator">&lt;&lt;</span><span class="token string">EOF
default:
  access_token_expire: 3600
  access_token_renew: 1800
  cors_allow_origins: []
  database_url: 'mysql://skyline:Skyline_123@192.168.233.240:3306/skyline'
  debug: false
  log_dir: ./log
  prometheus_basic_auth_password: ''
  prometheus_basic_auth_user: ''
  prometheus_enable_basic_auth: false
  prometheus_endpoint: http://192.168.233.240:9091
  secret_key: aCtmgbcUqYUy_HNVg5BDXCaeJgJQzHJXwqbXr0Nmb2o
  session_name: session
developer:
  show_raw_sql: false
openstack:
  keystone_url: http://192.168.233.240:35357/v3
  default_region: RegionOne
  interface_type: internal
  system_user_name: skyline
  system_user_password: Skyline_123
  base_domains:
  - heat_user_domain
  base_roles:
  - keystone_system_admin
  - keystone_system_reader
  - keystone_project_admin
  - keystone_project_member
  - keystone_project_reader
  - nova_system_admin
  - nova_system_reader
  - nova_project_admin
  - nova_project_member
  - nova_project_reader
  - cinder_system_admin
  - cinder_system_reader
  - cinder_project_admin
  - cinder_project_member
  - cinder_project_reader
  - glance_system_admin
  - glance_system_reader
  - glance_project_admin
  - glance_project_member
  - glance_project_reader
  - neutron_system_admin
  - neutron_system_reader
  - neutron_project_admin
  - neutron_project_member
  - neutron_project_reader
  - heat_system_admin
  - heat_system_reader
  - heat_project_admin
  - heat_project_member
  - heat_project_reader
  - placement_system_admin
  - placement_system_reader
  - panko_system_admin
  - panko_system_reader
  - panko_project_admin
  - panko_project_member
  - panko_project_reader
  - ironic_system_admin
  - ironic_system_reader
  - octavia_system_admin
  - octavia_system_reader
  - octavia_project_admin
  - octavia_project_member
  - octavia_project_reader
  default_region: RegionOne
  extension_mapping:
    fwaas_v2: neutron_firewall
    vpnaas: neutron_vpn
  interface_type: public
  keystone_url: http://192.168.233.240:35357/v3/
  nginx_prefix: /api/openstack
  reclaim_instance_interval: 604800
  service_mapping:
    baremetal: ironic
    compute: nova
    database: trove
    identity: keystone
    image: glance
    load-balancer: octavia
    network: neutron
    object-store: swift
    orchestration: heat
    placement: placement
    volumev3: cinder
  system_admin_roles:
  - admin
  - system_admin
  system_project: 'service'
  system_project_domain: 'Default'
  system_reader_roles:
  - system_reader
  system_user_domain: Default
  system_user_name: skyline
  system_user_password: 'Skyline_123'
setting:
  base_settings:
  - flavor_families
  - gpu_models
  - usb_models
  flavor_families:
  - architecture: x86_architecture
    categories:
    - name: general_purpose
      properties: []
    - name: compute_optimized
      properties: []
    - name: memory_optimized
      properties: []
    - name: high_clock_speed
      properties: []
  - architecture: heterogeneous_computing
    categories:
    - name: compute_optimized_type_with_gpu
      properties: []
    - name: visualization_compute_optimized_type_with_gpu
      properties: []
  gpu_models:
  - nvidia_t4
  usb_models:
  - usb_c
EOF</span>

<span class="token comment">#允许skyline引导依赖</span>
<span class="token function">docker</span> run <span class="token parameter variable">-d</span> <span class="token parameter variable">--name</span> skyline_bootstrap <span class="token parameter variable">-e</span> <span class="token assign-left variable">KOLLA_BOOTSTRAP</span><span class="token operator">=</span><span class="token string">""</span> <span class="token parameter variable">-v</span> /etc/skyline/skyline.yaml:/etc/skyline/skyline.yaml <span class="token parameter variable">--net</span><span class="token operator">=</span>host 99cloud/skyline:latest

<span class="token comment">#查看日志</span>
<span class="token function">docker</span> logs skyline_bootstrap
<span class="token comment">#查看最后日志是否为exit 0，如果不是请检查</span>
<span class="token punctuation">[</span>root@allinone cinder<span class="token punctuation">]</span><span class="token comment"># docker logs skyline_bootstrap</span>
+ <span class="token builtin class-name">echo</span> <span class="token string">'/usr/local/bin/gunicorn -c /etc/skyline/gunicorn.py skyline_apiserver.main:app'</span>
+ <span class="token builtin class-name">mapfile</span> <span class="token parameter variable">-t</span> CMD
++ <span class="token function">tail</span> /run_command
++ <span class="token function">xargs</span> <span class="token parameter variable">-n</span> <span class="token number">1</span>
+ <span class="token punctuation">[</span><span class="token punctuation">[</span> <span class="token parameter variable">-n</span> <span class="token number">0</span> <span class="token punctuation">]</span><span class="token punctuation">]</span>
+ <span class="token builtin class-name">cd</span> /skyline-apiserver/
+ <span class="token function">make</span> db_sync
alembic <span class="token parameter variable">-c</span> skyline_apiserver/db/alembic/alembic.ini upgrade <span class="token function">head</span>
<span class="token number">2022</span>-12-14 05:22:08.626 <span class="token operator">|</span> INFO     <span class="token operator">|</span> alembic.runtime.migration:__init__:204 - Context impl MySQLImpl.
<span class="token number">2022</span>-12-14 05:22:08.626 <span class="token operator">|</span> INFO     <span class="token operator">|</span> alembic.runtime.migration:__init__:207 - Will assume non-transactional DDL.
<span class="token number">2022</span>-12-14 05:22:08.633 <span class="token operator">|</span> INFO     <span class="token operator">|</span> alembic.runtime.migration:run_migrations:618 - Running upgrade  -<span class="token operator">></span> 000, init
+ <span class="token builtin class-name">exit</span> <span class="token number">0</span>

<span class="token comment">#删除引导依赖</span>
<span class="token function">docker</span> <span class="token function">rm</span> <span class="token parameter variable">-f</span> skyline_bootstrap
<span class="token comment">#启动skyline服务</span>
<span class="token function">docker</span> run <span class="token parameter variable">-d</span> <span class="token parameter variable">--name</span> skyline <span class="token parameter variable">--restart</span><span class="token operator">=</span>always <span class="token parameter variable">-v</span> /etc/skyline/skyline.yaml:/etc/skyline/skyline.yaml <span class="token parameter variable">--net</span><span class="token operator">=</span>host 99cloud/skyline:latest<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>
                
            </div>
            <hr/>

            

    <div class="reprint" id="reprint-statement">
        
            <div class="reprint__author">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-user">
                        文章作者:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="/about" rel="external nofollow noreferrer">Mr.Rootkit</a>
                </span>
            </div>
            <div class="reprint__type">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-link">
                        文章链接:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="https://zerohacker.gitee.io/2023/06/12/centos7%E9%83%A8%E7%BD%B2kolla-openstack%E5%AE%98%E6%96%B9%E6%95%99%E7%A8%8B/">https://zerohacker.gitee.io/2023/06/12/centos7%E9%83%A8%E7%BD%B2kolla-openstack%E5%AE%98%E6%96%B9%E6%95%99%E7%A8%8B/</a>
                </span>
            </div>
            <div class="reprint__notice">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-copyright">
                        版权声明:
                    </i>
                </span>
                <span class="reprint-info">
                    本博客所有文章除特別声明外，均采用
                    <a href="https://creativecommons.org/licenses/by/4.0/deed.zh" rel="external nofollow noreferrer" target="_blank">CC BY 4.0</a>
                    许可协议。转载请注明来源
                    <a href="/about" target="_blank">Mr.Rootkit</a>
                    !
                </span>
            </div>
        
    </div>

    <script async defer>
      document.addEventListener("copy", function (e) {
        let toastHTML = '<span>复制成功，请遵循本文的转载规则</span><button class="btn-flat toast-action" onclick="navToReprintStatement()" style="font-size: smaller">查看</a>';
        M.toast({html: toastHTML})
      });

      function navToReprintStatement() {
        $("html, body").animate({scrollTop: $("#reprint-statement").offset().top - 80}, 800);
      }
    </script>



            <div class="tag_share" style="display: block;">
                <div class="post-meta__tag-list" style="display: inline-block;">
                    
                        <div class="article-tag">
                            
                                <a href="/tags/%E4%BA%91%E8%AE%A1%E7%AE%97/">
                                    <span class="chip bg-color">云计算</span>
                                </a>
                            
                                <a href="/tags/%E8%99%9A%E6%8B%9F%E5%8C%96%E6%8A%80%E6%9C%AF/">
                                    <span class="chip bg-color">虚拟化技术</span>
                                </a>
                            
                                <a href="/tags/iaas/">
                                    <span class="chip bg-color">iaas</span>
                                </a>
                            
                                <a href="/tags/kolla-openstack/">
                                    <span class="chip bg-color">kolla-openstack</span>
                                </a>
                            
                        </div>
                    
                </div>
                <div class="post_share" style="zoom: 80%; width: fit-content; display: inline-block; float: right; margin: -0.15rem 0;">
                    <link rel="stylesheet" type="text/css" href="/libs/share/css/share.min.css">
<div id="article-share">

    
    <div class="social-share" data-sites="twitter,facebook,google,qq,qzone,wechat,weibo,douban,linkedin" data-wechat-qrcode-helper="<p>微信扫一扫即可分享！</p>"></div>
    <script src="/libs/share/js/social-share.min.js"></script>
    

    

</div>

                </div>
            </div>
            
                <div id="reward">
    <a href="#rewardModal" class="reward-link modal-trigger btn-floating btn-medium waves-effect waves-light red">赏</a>

    <!-- Modal Structure -->
    <div id="rewardModal" class="modal">
        <div class="modal-content">
            <a class="close modal-close"><i class="fas fa-times"></i></a>
            <h4 class="reward-title">你的赏识是我前进的动力</h4>
            <div class="reward-content">
                <div class="reward-tabs">
                    <ul class="tabs row">
                        <li class="tab col s6 alipay-tab waves-effect waves-light"><a href="#alipay">支付宝</a></li>
                        <li class="tab col s6 wechat-tab waves-effect waves-light"><a href="#wechat">微 信</a></li>
                    </ul>
                    <div id="alipay">
                        <img src="/medias/reward/alipay.jpg" class="reward-img" alt="支付宝打赏二维码">
                    </div>
                    <div id="wechat">
                        <img src="/medias/reward/wechat.png" class="reward-img" alt="微信打赏二维码">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        $('.tabs').tabs();
    });
</script>

            
        </div>
    </div>

    

    

    

    

    

    

    

    

    

<article id="prenext-posts" class="prev-next articles">
    <div class="row article-row">
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge left-badge text-color">
                <i class="fas fa-chevron-left"></i>&nbsp;上一篇</div>
            <div class="card">
                <a href="/2023/06/13/%E5%BF%AB%E9%80%9F%E9%83%A8%E7%BD%B2%E4%B8%80%E5%A5%97k3s%E9%9B%86%E7%BE%A4/">
                    <div class="card-image">
                        
                        <img src="/images/%E5%BF%AB%E9%80%9F%E9%83%A8%E7%BD%B2%E4%B8%80%E5%A5%97k3s%E9%9B%86%E7%BE%A4/top.jpg" class="responsive-img" alt="快速部署一套k3s集群">
                        
                        <span class="card-title">快速部署一套k3s集群</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            K3s 是一个轻量级的、完全兼容的 Kubernetes 发行版本。非常适合初学者。
                        
                    </div>
                    <div class="publish-info">
                        <span class="publish-date">
                            <i class="far fa-clock fa-fw icon-date"></i>2023-06-13
                        </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/categories/%E4%BA%91%E5%8E%9F%E7%94%9F/" class="post-category">
                                    云原生
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/tags/%E4%BA%91%E8%AE%A1%E7%AE%97/">
                        <span class="chip bg-color">云计算</span>
                    </a>
                    
                    <a href="/tags/%E5%AE%B9%E5%99%A8%E5%8C%96%E6%8A%80%E6%9C%AF/">
                        <span class="chip bg-color">容器化技术</span>
                    </a>
                    
                    <a href="/tags/pass/">
                        <span class="chip bg-color">pass</span>
                    </a>
                    
                    <a href="/tags/k3s/">
                        <span class="chip bg-color">k3s</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge right-badge text-color">
                本篇&nbsp;<i class="far fa-dot-circle"></i>
            </div>
            <div class="card">
                <a href="/2023/06/12/centos7%E9%83%A8%E7%BD%B2kolla-openstack%E5%AE%98%E6%96%B9%E6%95%99%E7%A8%8B/">
                    <div class="card-image">
                        
                        <img src="/images/centos7%E9%83%A8%E7%BD%B2kolla-openstack%E5%AE%98%E6%96%B9%E6%95%99%E7%A8%8B/top.jpg" class="responsive-img" alt="centos7.9部署的kolla-openstack官方教程">
                        
                        <span class="card-title">centos7.9部署的kolla-openstack官方教程</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            基于centos7.9部署的kolla-openstack虚拟化IAAS平台
                        
                    </div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2023-06-12
                            </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/categories/%E4%BA%91%E8%AE%A1%E7%AE%97/" class="post-category">
                                    云计算
                                </a>
                            
                            
                        </span>
                    </div>
                </div>

                
                <div class="card-action article-tags">
                    
                    <a href="/tags/%E4%BA%91%E8%AE%A1%E7%AE%97/">
                        <span class="chip bg-color">云计算</span>
                    </a>
                    
                    <a href="/tags/%E8%99%9A%E6%8B%9F%E5%8C%96%E6%8A%80%E6%9C%AF/">
                        <span class="chip bg-color">虚拟化技术</span>
                    </a>
                    
                    <a href="/tags/iaas/">
                        <span class="chip bg-color">iaas</span>
                    </a>
                    
                    <a href="/tags/kolla-openstack/">
                        <span class="chip bg-color">kolla-openstack</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
    </div>
</article>

</div>



<!-- 代码块功能依赖 -->
<script type="text/javascript" src="/libs/codeBlock/codeBlockFuction.js"></script>


  <!-- 是否加载使用自带的 prismjs. -->
  <script type="text/javascript" src="/libs/prism/prism.min.js"></script>


<!-- 代码语言 -->

<script type="text/javascript" src="/libs/codeBlock/codeLang.js"></script>


<!-- 代码块复制 -->

<script type="text/javascript" src="/libs/codeBlock/codeCopy.js"></script>


<!-- 代码块收缩 -->

<script type="text/javascript" src="/libs/codeBlock/codeShrink.js"></script>



    </div>
    <div id="toc-aside" class="expanded col l3 hide-on-med-and-down">
        <div class="toc-widget card" style="background-color: white;">
            <div class="toc-title"><i class="far fa-list-alt"></i>&nbsp;&nbsp;目录</div>
            <div id="toc-content"></div>
        </div>
    </div>
</div>

<!-- TOC 悬浮按钮. -->

<div id="floating-toc-btn" class="hide-on-med-and-down">
    <a class="btn-floating btn-large bg-color">
        <i class="fas fa-list-ul"></i>
    </a>
</div>


<script src="/libs/tocbot/tocbot.min.js"></script>
<script>
    $(function () {
        tocbot.init({
            tocSelector: '#toc-content',
            contentSelector: '#articleContent',
            headingsOffset: -($(window).height() * 0.4 - 45),
            collapseDepth: Number('0'),
            headingSelector: 'h2, h3, h4'
        });

        // Set scroll toc fixed.
        let tocHeight = parseInt($(window).height() * 0.4 - 64);
        let $tocWidget = $('.toc-widget');
        $(window).scroll(function () {
            let scroll = $(window).scrollTop();
            /* add post toc fixed. */
            if (scroll > tocHeight) {
                $tocWidget.addClass('toc-fixed');
            } else {
                $tocWidget.removeClass('toc-fixed');
            }
        });

        
        /* 修复文章卡片 div 的宽度. */
        let fixPostCardWidth = function (srcId, targetId) {
            let srcDiv = $('#' + srcId);
            if (srcDiv.length === 0) {
                return;
            }

            let w = srcDiv.width();
            if (w >= 450) {
                w = w + 21;
            } else if (w >= 350 && w < 450) {
                w = w + 18;
            } else if (w >= 300 && w < 350) {
                w = w + 16;
            } else {
                w = w + 14;
            }
            $('#' + targetId).width(w);
        };

        // 切换TOC目录展开收缩的相关操作.
        const expandedClass = 'expanded';
        let $tocAside = $('#toc-aside');
        let $mainContent = $('#main-content');
        $('#floating-toc-btn .btn-floating').click(function () {
            if ($tocAside.hasClass(expandedClass)) {
                $tocAside.removeClass(expandedClass).hide();
                $mainContent.removeClass('l9');
            } else {
                $tocAside.addClass(expandedClass).show();
                $mainContent.addClass('l9');
            }
            fixPostCardWidth('artDetail', 'prenext-posts');
        });
        
    });
</script>

    

</main>




    <footer class="page-footer bg-color">
    
        <link rel="stylesheet" href="/libs/aplayer/APlayer.min.css">
<style>
    .aplayer .aplayer-lrc p {
        
        display: none;
        
        font-size: 12px;
        font-weight: 700;
        line-height: 16px !important;
    }

    .aplayer .aplayer-lrc p.aplayer-lrc-current {
        
        display: none;
        
        font-size: 15px;
        color: #42b983;
    }

    
    .aplayer.aplayer-fixed.aplayer-narrow .aplayer-body {
        left: -66px !important;
    }

    .aplayer.aplayer-fixed.aplayer-narrow .aplayer-body:hover {
        left: 0px !important;
    }

    
</style>
<div class="">
    
    <div class="row">
        <meting-js class="col l8 offset-l2 m10 offset-m1 s12"
                   server="netease"
                   type="playlist"
                   id="503838841"
                   fixed='true'
                   autoplay='false'
                   theme='#42b983'
                   loop='all'
                   order='random'
                   preload='auto'
                   volume='0.7'
                   list-folded='true'
        >
        </meting-js>
    </div>
</div>

<script src="/libs/aplayer/APlayer.min.js"></script>
<script src="/libs/aplayer/Meting.min.js"></script>

    

    <div class="container row center-align"
         style="margin-bottom: 0px !important;">
        <div class="col s12 m8 l8 copy-right">
            Copyright&nbsp;&copy;
            
                <span id="year">2019-2023</span>
            
            <a href="/about" target="_blank">Mr.Rootkit</a>
            |&nbsp;Powered by&nbsp;<a href="https://hexo.io/" target="_blank">Hexo</a>
            |&nbsp;Theme&nbsp;<a href="https://github.com/blinkfox/hexo-theme-matery" target="_blank">Matery</a>
            
            <br>
            
            
            
                
            
            
                <span id="busuanzi_container_site_pv">
                &nbsp;|&nbsp;<i class="far fa-eye"></i>&nbsp;总访问量:&nbsp;
                    <span id="busuanzi_value_site_pv" class="white-color"></span>
            </span>
            
            
                <span id="busuanzi_container_site_uv">
                &nbsp;|&nbsp;<i class="fas fa-users"></i>&nbsp;总访问人数:&nbsp;
                    <span id="busuanzi_value_site_uv" class="white-color"></span>
            </span>
            
            <br>

            <!-- 运行天数提醒. -->
            
            <br>
            
        </div>
        <div class="col s12 m4 l4 social-link social-statis">
    <a href="https://github.com/liangyoufeng" class="tooltipped" target="_blank" data-tooltip="访问我的GitHub" data-position="top" data-delay="50">
        <i class="fab fa-github"></i>
    </a>



    <a href="mailto:254785258@qq.com" class="tooltipped" target="_blank" data-tooltip="邮件联系我" data-position="top" data-delay="50">
        <i class="fas fa-envelope-open"></i>
    </a>







    <a href="tencent://AddContact/?fromId=50&fromSubId=1&subcmd=all&uin=254785258" class="tooltipped" target="_blank" data-tooltip="QQ联系我: 254785258" data-position="top" data-delay="50">
        <i class="fab fa-qq"></i>
    </a>







    <a href="/atom.xml" class="tooltipped" target="_blank" data-tooltip="RSS 订阅" data-position="top" data-delay="50">
        <i class="fas fa-rss"></i>
    </a>

</div>
    </div>
</footer>

<div class="progress-bar"></div>


    <!-- 搜索遮罩框 -->
<div id="searchModal" class="modal">
    <div class="modal-content">
        <div class="search-header">
            <span class="title"><i class="fas fa-search"></i>&nbsp;&nbsp;搜索</span>
            <input type="search" id="searchInput" name="s" placeholder="请输入搜索的关键字"
                   class="search-input">
        </div>
        <div id="searchResult"></div>
    </div>
</div>

<script type="text/javascript">
$(function () {
    var searchFunc = function (path, search_id, content_id) {
        'use strict';
        $.ajax({
            url: path,
            dataType: "xml",
            success: function (xmlResponse) {
                // get the contents from search data
                var datas = $("entry", xmlResponse).map(function () {
                    return {
                        title: $("title", this).text(),
                        content: $("content", this).text(),
                        url: $("url", this).text()
                    };
                }).get();
                var $input = document.getElementById(search_id);
                var $resultContent = document.getElementById(content_id);
                $input.addEventListener('input', function () {
                    var str = '<ul class=\"search-result-list\">';
                    var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
                    $resultContent.innerHTML = "";
                    if (this.value.trim().length <= 0) {
                        return;
                    }
                    // perform local searching
                    datas.forEach(function (data) {
                        var isMatch = true;
                        var data_title = data.title.trim().toLowerCase();
                        var data_content = data.content.trim().replace(/<[^>]+>/g, "").toLowerCase();
                        var data_url = data.url;
                        data_url = data_url.indexOf('/') === 0 ? data.url : '/' + data_url;
                        var index_title = -1;
                        var index_content = -1;
                        var first_occur = -1;
                        // only match artiles with not empty titles and contents
                        if (data_title !== '' && data_content !== '') {
                            keywords.forEach(function (keyword, i) {
                                index_title = data_title.indexOf(keyword);
                                index_content = data_content.indexOf(keyword);
                                if (index_title < 0 && index_content < 0) {
                                    isMatch = false;
                                } else {
                                    if (index_content < 0) {
                                        index_content = 0;
                                    }
                                    if (i === 0) {
                                        first_occur = index_content;
                                    }
                                }
                            });
                        }
                        // show search results
                        if (isMatch) {
                            str += "<li><a href='" + data_url + "' class='search-result-title'>" + data_title + "</a>";
                            var content = data.content.trim().replace(/<[^>]+>/g, "");
                            if (first_occur >= 0) {
                                // cut out 100 characters
                                var start = first_occur - 20;
                                var end = first_occur + 80;
                                if (start < 0) {
                                    start = 0;
                                }
                                if (start === 0) {
                                    end = 100;
                                }
                                if (end > content.length) {
                                    end = content.length;
                                }
                                var match_content = content.substr(start, end);
                                // highlight all keywords
                                keywords.forEach(function (keyword) {
                                    var regS = new RegExp(keyword, "gi");
                                    match_content = match_content.replace(regS, "<em class=\"search-keyword\">" + keyword + "</em>");
                                });

                                str += "<p class=\"search-result\">" + match_content + "...</p>"
                            }
                            str += "</li>";
                        }
                    });
                    str += "</ul>";
                    $resultContent.innerHTML = str;
                });
            }
        });
    };

    searchFunc('/search.xml', 'searchInput', 'searchResult');
});
</script>

    <!-- 白天和黑夜主题 -->
<div class="stars-con">
    <div id="stars"></div>
    <div id="stars2"></div>
    <div id="stars3"></div>  
</div>

<script>
    function switchNightMode() {
        $('<div class="Cuteen_DarkSky"><div class="Cuteen_DarkPlanet"></div></div>').appendTo($('body')),
        setTimeout(function () {
            $('body').hasClass('DarkMode') 
            ? ($('body').removeClass('DarkMode'), localStorage.setItem('isDark', '0'), $('#sum-moon-icon').removeClass("fa-sun").addClass('fa-moon')) 
            : ($('body').addClass('DarkMode'), localStorage.setItem('isDark', '1'), $('#sum-moon-icon').addClass("fa-sun").removeClass('fa-moon')),
            
            setTimeout(function () {
            $('.Cuteen_DarkSky').fadeOut(1e3, function () {
                $(this).remove()
            })
            }, 2e3)
        })
    }
</script>

    <!-- 回到顶部按钮 -->
<div id="backTop" class="top-scroll">
    <a class="btn-floating btn-large waves-effect waves-light" href="#!">
        <i class="fas fa-arrow-up"></i>
    </a>
</div>


    <script src="/libs/materialize/materialize.min.js"></script>
    <script src="/libs/masonry/masonry.pkgd.min.js"></script>
    <script src="/libs/aos/aos.js"></script>
    <script src="/libs/scrollprogress/scrollProgress.min.js"></script>
    <script src="/libs/lightGallery/js/lightgallery-all.min.js"></script>
    <script src="/js/matery.js"></script>

    

    
    
    

    <!-- 雪花特效 -->
    

    <!-- 鼠标星星特效 -->
    

     
        <script src="https://ssl.captcha.qq.com/TCaptcha.js"></script>
        <script src="/libs/others/TencentCaptcha.js"></script>
        <button id="TencentCaptcha" data-appid="xxxxxxxxxx" data-cbfn="callback" type="button" hidden></button>
    

    <!-- Baidu Analytics -->

    <!-- Baidu Push -->

<script>
    (function () {
        var bp = document.createElement('script');
        var curProtocol = window.location.protocol.split(':')[0];
        if (curProtocol === 'https') {
            bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
        } else {
            bp.src = 'http://push.zhanzhang.baidu.com/push.js';
        }
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(bp, s);
    })();
</script>

    
    <script src="/libs/others/clicklove.js" async="async"></script>
    
    
    <script async src="/libs/others/busuanzi.pure.mini.js"></script>
    

    

    

    <!--腾讯兔小巢-->
    
    

    

    

    
    <script src="/libs/instantpage/instantpage.js" type="module"></script>
    

</body>

</html>
